{% extends 'base.html' %}
{% load url from future %}

{% block extra_style %}
{% load static %}
<link rel="stylesheet"
  href='{% get_static_prefix %}css/site.css' 
  type="text/css" media="all" />
{% endblock %}

{% block java_script %}
{% load static %}
<script type='text/javascript' 
  src='{% get_static_prefix %}js/warranty.js'>
</script>
{% endblock %}

{% block content %}
{% load report_extras %}

<div class="row-fluid">
<div class="span1">
  <img src='https://km.support.apple.com.edgekey.net/kb/securedImage.jsp?configcode={{machine.serial_number|slice:"8:" }}&size=72x72' />
</div>
  <div class="span10">
    <h2>{{ machine.hostname }}</h2>
    {% if model_lookup_enabled and additional_info.model_description|length > 1 %}
      <h3><small>{{ additional_info.model_description }}</small></h3>
    {% endif %}
    <p>
      <b>Report</b> 
      <span title="Last report date">
              :: {{ machine.last_munki_update|date:"Y-m-d H:i" }}
      </span>
      | <a href='{% url "inventory.views.detail" machine.mac %}'>Inventory</a>
    </p>
  </div>
</div>

<div class="row-fluid">
  <div class="span6">
    <h3>Machine</h3>
    <table class="client_info table table-condensed">
      <tbody>
        <tr>
          <th>Model:</th>
          <td>
            {{ machine.machine_model }}
            {{ machine.cpu_type }}
            {{ machine.cpu_speed}}
          </td>
        </tr>
        <tr>
          <th>RAM:</th>
          <td>{{ machine.ram }}</td>
        </tr>
        <tr>
          <th>Serial:</th>
          <td>{{ machine.serial_number }}</td>
        </tr>
        <tr>
          <th>MAC:</th>
          <td>{{ machine.mac }}</td>
        </tr>
        <tr>
          <th>Remote IP:</th>
          <td>{{ machine.remote_ip }}</td>
        </tr>
        {% if 'MachineInfo' in report %}
        <tr>
          <th>Hostname:</th>
          <td>{{ report.MachineInfo.hostname }}</td>
        </tr>
        <tr>
          <th>OS version:</th>
          <td>{{ report.MachineInfo.os_vers }}
              {{ report.MachineInfo.arch }}</td>
        </tr>
        {% endif %}
        <tr>
          <th>Free disk space:</th>
          <td>{{ report.AvailableDiskSpace|humanreadablesize  }}</td>
        </tr>
        <tr>
          <th>Console user:</th>
          <td>{{ report.ConsoleUser }}</td>
        </tr>
      </tbody>
    </table>
  </div>
  <div class='span4'>
    <h3>Munki</h3>
    <table class="client_info table table-condensed">
      <tbody>
        <tr>
          <th>Version:</th>
          <td>{{ report.ManagedInstallVersion }}</td>
        </tr>
        {% if 'ManifestName' in report %}
        <tr>
          <th>Manifest:</th>
          <td>
            <a href='{% url "manifests.views.view" report.ManifestNameLink %}'>
            {{ report.ManifestName }}</a>
          </td>
        </tr>
        {% endif %}
        <tr>
          <th>Run Type:</th>
          <td>{{ report.RunType }}</td>
        </tr>
        <tr>
          <th>Start:</th>
          <td>{{ report.StartTime }}</td>
        </tr>
        <tr>
          <th>End:</th>
          <td>{{ report.EndTime }}</td>
        </tr>
      </tbody>
    </table>
    {% if warranty_lookup_enabled %}
    <h3>Warranty Information</h3>
    <table class="client_info table table-condensed">
      <tbody>
        <tr>
          <th>Warranty status:</th>
          <td>
            <span id='warranty_status_checking' style='display: none;'>
              Checking warranty status 
              <img src="{% get_static_prefix %}img/loading.gif" height="20" width="20"/>
            </span>
            <span id='warranty_status'>
              <a href='javascript:void(0)' onclick="get_warranty_status('{{ machine.serial_number }}')">Check status</a>
            </span>
          </td>
        </tr>
        <tr>
          <th>Manufacture date:</th>
          <td>{{ additional_info.manufacture_date }}</td>
        </tr>
      </tbody>
    </table>
    {% endif %}
  </div>
</div>

<div class="row-fluid">
  <div class="span12">
<a name="errors">&nbsp;</a>
<h3>Errors <span class="badge badge-important">{{ report.Errors|length }}</span>        </h3>
{% if report.Errors|length %}
  <pre class="text-error">{{ report.Errors|join:'<br>' }}</pre>
{% endif %}
<h3>Warnings <span class="badge badge-warning">{{ report.Warnings|length }}</span></h3>
{% if report.Warnings|length %}
  <pre class="text-warning">{{ report.Warnings|join:'<br>' }}</pre>
{% endif %}
  </div>
</div>

<div class="row-fluid">
  <div class="span8">
{% with title='Apple Updates' pkglist=report.AppleUpdates %}
  {% include 'reports/pkgtable.html' %}
{% endwith %}
{% with title='Active Installs' pkglist=report.ItemsToInstall %}
  {% include 'reports/pkgtable.html' %}
{% endwith %}
{% with title='Active Removals' pkglist=report.ItemsToRemove %}
  {% include 'reports/pkgtable.html' %}
{% endwith %}
{% with title='Problem Installs' pkglist=report.ProblemInstalls %}
  {% include 'reports/pkgtable.html' %}
{% endwith %}
  </div>
</div>

<div class="row-fluid">
  <div class="span8">
      {% with title='Managed Installs' pkglist=report.ManagedInstalls %}
        {% include 'reports/pkgtable.html' %}
      {% endwith %}
  </div>
  <div class="span4">
      {% if 'managed_uninstalls_list' in report %}
        <h3>Managed Uninstalls <span class="badge badge-info">{{ report.managed_uninstalls_list|length }}</span></h3>
        <table class="client_info table table-striped table-condensed">
          <thead>
            <tr>
              <th>Name</th>
              <th>Status</th>
            </tr>
          </thead>
          <tbody>
            {% for item in report.managed_uninstalls_list %}
            <tr>
              <td>{{ item }}</td>
              {% if item in report.RemovedItems %}
                <td>not installed</td>
              {% else %}
                <td class='error'>installed</td>
              {% endif %}
            </tr>
            {% endfor %}
          </tbody>
        </table>
      {% endif %}
  </div>
</div>

{% endblock %}
